// 商品类
class Item {
    constructor(itemId, itemName, price) {
        // 字符串
        this.itemId = itemId
        // 字符串
        this.itemName = itemName
        // 数字
        this.price = price
        // promotion 为对象{}
        this.promotion = {}
    }

    static addItem(itemList, item) {
        itemList[item.itemId] = item
    }

    // 为单件商品添加单个优惠
    itemAddPromotion(promotionId, promotionType, promotionList) {
        this.promotion[promotionType] = promotionList[promotionId]
    }

    // 为单件商品添加多个优惠
    itemAddPromotionList(promotionIdList, promotionList) {
        for (const e of promotionIdList) {
            this.itemAddPromotion(e[0], e[1], promotionList)
        }
    }

    // 清空优惠
    clearItemPromotion() {
        this.promotion = {}
    }

}
